<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>添加尺码</h2>
    </div>
    <form action="{:U('sizeaction')}" method="post" id='for' class="form-horizontal">
        <select name="size" id="" style="width:100px;" class="sel">
        <empty name="details">
            <option  value="{$size['details_id']}">尺码齐全</option>
        <else />
            <foreach name="details" item="size"  >    
                <option  value="{$size['details_id']}">{$size['size']}</option>
            </foreach>
        </empty> 
        
        </select>

        <input type="hidden" value="{$goods_id}" name="goods_id" class="goods_id">

        <div class="form-item">
            <label class="item-label">对应尺码的数量</label>
            <div class="controls">
                <input type="text" id='store' class="text input-large" name="store" value="{$info['price']}">
            </div>
            <span id='st'></span>
        </div>
       
        <div class="form-item">
            <button class="btn submit-btn" id="sub" type="submit" target-form="form-horizontal">确 定</button>

            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Goods/showlist')}');

        $(function(){
            
            var sign = false;
            var ok2 = false;

            $('.sel').change(function(){
                ok2 = true;
            });

            var str = $('#store').val().length;
            if (str == 0) {
                sign = false;
            }else{
                reg = /^\d{0,10}$/;

                var v = $('#store').val();
                if(!reg.test(v)){
                    sign = false;
                }else{
                    $('#st').html('');
                    sign = true;
                }
            }


            //验证库存
            $('#store').blur(function(){
                var str = $(this).val().length;
                if (str == 0) {
                    $('#st').html('库存不能为空').css('color' , 'red');
                    sign = false;
                }else{
                    reg = /^\d{1,10}\.*\d{0,2}$/;

                    var v = $(this).val();
                    if(!reg.test(v)){
                        $('#st').html('只能是数字').css('color' , 'red');
                        sign = false;
                    }else{
                        $('#st').html('');
                        sign = true;
                    }
                }
            });

            $('#sub').click(function(){
                if (sign == false && ok2 == false) {
                    return false;
                };
            });
        });

    </script>
</block>
